﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.performace
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int pid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(pid);
				}
			}
		}
			
	private void ShowInfo(int pid)
	{
		lcs.BLL.performace bll=new lcs.BLL.performace();
		lcs.Model.performace model=bll.GetModel(pid);
		this.lblpid.Text=model.pid.ToString();
		this.txtuid.Text=model.uid.ToString();
		this.txtpdate.Text=model.pdate.ToString();
		this.txtoper.Text=model.oper;
		this.txtresult.Text=model.result;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtuid.Text))
			{
				strErr+="uid格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtpdate.Text))
			{
				strErr+="pdate格式错误！\\n";	
			}
			if(this.txtoper.Text.Trim().Length==0)
			{
				strErr+="oper不能为空！\\n";	
			}
			if(this.txtresult.Text.Trim().Length==0)
			{
				strErr+="result不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int pid=int.Parse(this.lblpid.Text);
			int uid=int.Parse(this.txtuid.Text);
			DateTime pdate=DateTime.Parse(this.txtpdate.Text);
			string oper=this.txtoper.Text;
			string result=this.txtresult.Text;


			lcs.Model.performace model=new lcs.Model.performace();
			model.pid=pid;
			model.uid=uid;
			model.pdate=pdate;
			model.oper=oper;
			model.result=result;

			lcs.BLL.performace bll=new lcs.BLL.performace();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
